<?php
class ModelTicketInstall extends Model {
	public function install() {
		$this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "ticket(
			ticket_id int NOT NULL AUTO_INCREMENT,
			PRIMARY KEY(ticket_id),
			ticket_subject text,
			ticket_status varchar(255),
			ticket_created datetime,
			ticket_department_id int,
			ticket_customer_id int,
			ticket_user_id int,
			ticket_last_update varchar(255)
		)");
		
		$this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "department(
			department_id int NOT NULL AUTO_INCREMENT,
			PRIMARY KEY(department_id),
			department_name varchar(255)
		)");
		
		$this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "ticket_message(
			message_id int NOT NULL AUTO_INCREMENT,
			PRIMARY KEY(message_id),
			content text,
			is_user boolean,
			created datetime,
			ticket_id int,
			file varchar(255)
		)");
		
		$this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "ticket_assigner(
			id int NOT NULL AUTO_INCREMENT,
			PRIMARY KEY(id),
			user_group_id int
		)");
		
		print "Database is installed";
	}	
}
?>